jQuery(document).ready(function(t){"use strict";t.confetti=new function(){function n(t){this.x=Math.random()*g,this.y=Math.random()*v-v,this.r=r(5,15),this.d=Math.random()*b+10,this.color=t,this.tilt=Math.floor(10*Math.random())-10,this.tiltAngleIncremental=.07*Math.random()+.05,this.tiltAngle=0,this.draw=function(){return y.beginPath(),y.lineWidth=this.r/2,y.strokeStyle=this.color,y.moveTo(this.x+this.tilt+this.r/4,this.y),y.lineTo(this.x+this.tilt,this.y+this.tilt+this.r/4),y.stroke()}}function e(){i(),t(window).on("resize",function(){g=window.innerWidth,v=window.innerHeight,w.width=g,w.height=v})}function i(){t("#nasa-confetti").length<1&&(t("form.nasa-shopping-cart-form").length?t("body").append(''):t("#cart-sidebar").length?t("#cart-sidebar").append(''):t("body").append(''),t("#ns-cart-popup").length&&t("#ns-cart-popup").parents(".ns-cart-popup-wrap").prepend('')),t("#review_form_wrapper").length&&t("#nasa-confetti-review").length<1&&t("#review_form_wrapper").prepend(''),w=document.getElementById("nasa-confetti"),t("#ns-cart-popup").parents(".ns-cart-popup-wrap").hasClass("nasa-active")&&(w=document.getElementById("nasa-confetti-popup")),t("#review_form_wrapper").hasClass("ns-show")&&(w=document.getElementById("nasa-confetti-review")),y=w.getContext("2d"),g=window.innerWidth,v=window.innerHeight,w.width=g,w.height=v,q=!0}function o(){w.style.display="block",x=[],T=!1;for(var t=0;b>t;t++){var e=C.getColor();x.push(new n(e))}l()}function a(){b=t("body").hasClass("nasa-in-mobile")?50:300,y.clearRect(0,0,g,v);for(var n=[],e=0;b>e;e++)!function(t){n.push(x[t].draw())}(e);return s(),n}function r(t,n){return Math.floor(Math.random()*(n-t+1)+t)}function s(){var t,n=0;I+=.01,A+=.1;for(var e=0;b>e;e++){if(t=x[e],T)return;!F&&t.y<-15?t.y=v+100:(d(t,e),t.y<=v&&n++,c(t,e))}0===n&&p()}function c(t,n){(t.x>g+20||t.x<-20||t.y>v)&&F&&(n%5>0||n%2==0?h(t,Math.random()*g,-10,Math.floor(10*Math.random())-10):Math.sin(I)>0?h(t,-5,Math.random()*v,Math.floor(10*Math.random())-10):h(t,g+5,Math.random()*v,Math.floor(10*Math.random())-10))}function d(t,n){t.tiltAngle+=t.tiltAngleIncremental,t.y+=(Math.cos(I+t.d)+10+t.r/2)/2,t.x+=Math.sin(I),t.tilt=10*Math.sin(t.tiltAngle-n/3)}function h(t,n,e,i){t.x=n,t.y=e,t.tilt=i}function l(){q||e(),g=window.innerWidth,v=window.innerHeight,w.width=g,w.height=v,function t(){return T?null:(_=requestAnimFrame(t),a())}()}function f(){clearTimeout(M),clearTimeout(_)}function u(){F=!1,f()}function p(){q||e(),T=!0,"undefined"!=typeof y&&(y.clearRect(0,0,g,v),w.style.display="none")}function m(){q||e(),f(),p(),M=setTimeout(function(){F=!0,T=!1,o()},100)}var w,y,g,v,M,_,b=300,x=[],I=0,A=0,F=!0,T=!0,q=!1,C={colorOptions:["#EF2964","#00C09D","#2D87B0","#48485E","#EFFF1D"],colorIndex:0,colorIncrementer:0,colorThreshold:10,getColor:function(){return this.colorIncrementer>=10&&(this.colorIncrementer=0,this.colorIndex++,this.colorIndex>=this.colorOptions.length&&(this.colorIndex=0)),this.colorIncrementer++,this.colorOptions[this.colorIndex]}};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),this.init=e,this.start=o,this.stop=u,this.restart=m},t("body").on("nasa_confetti_init",function(){t.confetti.init()}),t("body").on("nasa_confetti_start",function(n,e){t.confetti.start(),"undefined"!=typeof e&&setTimeout(function(){t("body").trigger("nasa_confetti_stop")},e)}),t("body").on("nasa_confetti_restart",function(n,e){t.confetti.restart(),"undefined"!=typeof e&&setTimeout(function(){t("body").trigger("nasa_confetti_stop")},e)}),t("body").on("nasa_confetti_stop",function(){t.confetti.stop()})});